using System;
using System.Collections.Generic;
using System.Data;
using System.Data.OracleClient;
using System.Configuration;

public class CD_Usuarios
    {
        public DataSet Usuarios_DatosBase()
        {
            try
            {
                OracleCommand cmd = new OracleCommand();
                cmd.Connection = new OracleConnection(ConfigurationManager.ConnectionStrings["DESASITI"].ConnectionString);

                cmd.CommandTimeout = 0;
                cmd.CommandText = "SITIPROYECTOS.?NomPaquete.UsuariosDatosBase";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new OracleParameter("pEmpresas", OracleType.Cursor)).Direction = ParameterDirection.Output;
                cmd.Parameters.Add(new OracleParameter("pTiposEmpleados", OracleType.Cursor)).Direction = ParameterDirection.Output;

                OracleDataAdapter adapter = new OracleDataAdapter(cmd);
                DataSet set = new DataSet();
                adapter.Fill(set, "DatosUsuario");
                cmd.Connection.Close();

                return set;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public int Usuarios_Insertar(Usuarios pUsuarios) 
        {
            int pTransaccion = 0;
            try{
                OracleCommand cmd = new OracleCommand();
                cmd.Connection = new OracleConnection(ConfigurationManager.ConnectionStrings["DESASITI"].ConnectionString);

                cmd.CommandTimeout = 0;
                cmd.CommandText = "SITIPROYECTOS.?NomPaquete.UsuariosInsertarModificar";
                cmd.CommandType = CommandType.StoredProcedure;
				          cmd.Parameters.AddWithValue("pclave", pclave);
          cmd.Parameters.AddWithValue("pnombre", pnombre);
          cmd.Parameters.AddWithValue("pemail", pemail);
          cmd.Parameters.AddWithValue("pfechaalta", pfechaalta);
          cmd.Parameters.AddWithValue("pfechaultacc", pfechaultacc);
          cmd.Parameters.AddWithValue("psuperusu", psuperusu);
          cmd.Parameters.AddWithValue("pactivo", pactivo);
          cmd.Parameters.AddWithValue("ptipousu", ptipousu);

                cmd.Parameters.Add("pTransaccion", OracleType.Number).Direction = ParameterDirection.Output;
                
                cmd.Connection.Open();
                cmd.ExecuteNonQuery();
                pTransaccion = Int32.Parse(cmd.Parameters["pTransaccion"].Value.ToString());
                cmd.Connection.Close();

                return pTransaccion;
            }catch(Exception ex){
                throw ex;
            }
        }
		
	}
